<template>
  <div>
    <el-dialog
      :title="info.issAdd?'商品编辑':'商品添加'"
      :visible.sync="info.isshow"
      @closed="closed"
      width="60%"
    >
      {{form}}
      <el-form :model="form">
        <el-form-item label="手机号" label-width="120px">
          <el-input placeholder="请输入内容" v-model="form.phone" autocomplete></el-input>
        </el-form-item>
        <el-form-item label="昵称" label-width="120px">
          <el-input placeholder="请输入内容" v-model="form.nickname" autocomplete></el-input>
        </el-form-item>
        <el-form-item label="密码" label-width="120px">
          <el-input placeholder="请输入内容" v-model="form.password" autocomplete></el-input>
        </el-form-item>

        <el-form-item label="状态" label-width="120px">
          <el-switch v-model="form.status" :active-value="1" :inactive-value="2"></el-switch>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <!-- <el-button type="primary" v-if="info.isAdd" @click="add">添 加</el-button> -->
        <el-button type="primary"  @click="update">修 改</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import {  successAlert } from "../../../utils/alert";
import {
  reqmemberinfo,reqmemberedit
} from "../../../request/api";
import { mapGetters, mapActions } from "vuex";
export default {
  components: {},
  computed: {
    ...mapGetters({
      list: "cate/list",
    }),
  },
  mounted() {},
  props: ["info"],
  data() {
    return {
      form: {
        nickname: "",
        uid: "",
        phone: "",
        password:"",
        status: 2,
      },
    };
  },
  methods: {
    ...mapActions({
      reqList: "vip/reqList",
    }),
    // 点击取消
    cancel() {
      this.info.isshow = false;
    },
    //清空数据
    empty() {
      this.form = {
        nickname: "",
        uid: "",
        phone: "",
        password:"",
        status: 2,
      };
     
    },
    
    getOne(uid) {
      reqmemberinfo({ uid:uid }).then((res) => {
        if (res.data.code == 200) {
          this.form = res.data.list;
        }
      });
    },
    // form关闭
    closed() {
      if (!this.info.isAdd) {
        this.empty();
      }
    },
    //点击修改
    update() {
      reqmemberedit(this.form).then((res) => {
        if (res.data.code == 200) {
          successAlert(res.data.msg);
          this.cancel();
          this.empty();
          this.reqList();
        }
      });
    },
  },
};
</script>
<style lang="less">
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>